// pages/find/find.js
const {
  historyList,
  hotKeywords,
  goodsList
} = require("../../utils/util")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    value: '',
    historyList: [], //最近搜索关键词
    hotKeywords: [], //热点关键词
    goodsList: [], //主题数据集合
  },
  onLoad() {
    this.setData({
      historyList: historyList,
      hotKeywords: hotKeywords
    })
  },
  openPlay(){
    wx.navigateTo({
      url: "/pages/play/play"
    })
  },
  onChange(e) {
    this.setData({
      value: e.detail,
    });
  },
  onSearch() {
    if (this.data.value == null || this.data.value == "") {
      wx.showToast({
        title: '请输入关键词',
        icon: "error"
      })
      this.setData({
        goodsList:[],
      })
      return;
    }
    this.setData({
      goodsList: goodsList
    })
  },
  clearHistoryList() {
    this.setData({
      historyList: []
    })
  }
})